var subsets = function (nums) {
  let res = [], t = []
  const breakTreeshaking = (cur) => {
    if (cur === nums.length) {
      res.push([...t])
      return
    }
    t.push(nums[cur])
    breakTreeshaking(cur + 1)
    t.pop()
    breakTreeshaking(cur + 1)
  }
  breakTreeshaking(0)
  console.log(res);
  return res
};

let nums = [1, 2, 2]
subsets(nums)